package com.heima.common.exception;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionCatch {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public ResponseResult exception(Exception e) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "服务器维护请稍后重试");
    }

    @ExceptionHandler(MyException.class)
    @ResponseBody
    public ResponseResult myException(MyException e) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, e.getMessage());
    }
}
